<template>
  <el-button :loading="loading" :disabled="loading" type="primary" round @click="onClick">{{ loading ? '导出中' : '导出' }}</el-button>

</template>
<script>
import { exportFile } from '@/api'
import download from 'js-file-download'
export default {
  props: {
    fileName: String
  },
  data() {
    return {
      loading: false
    }
  },
  methods: {
    // 上传之前: 获取file对象进行参数验证
    onClick() {
      this.loading = true
      exportFile('/importData/uploadEstate').then(res => {
        this.$message.success(res.msg)
        this.loading = false
        download(res, this.fileName)
      }).catch(() => {
        this.$message.error('导出失败')
        this.loading = false
      })
      return false
    }
  }
}
</script>
<style lang="scss">
</style>
